<?php
    apf_require_class("PageHelper");
    $img_path = '/img/home/';
    ?>

<div class="header">
    <div class="bg_top"></div>
    <div class="logo"></div>
</div>

<div class="container">
    <h4>员工离职</h4>
    <table>
        <tr>
            <td style="padding-left: 48px;"><label>姓名：</label><?php echo $userdata['user_name'],'-',$userdata['user_code'];?></td>
            <td><label>部门：</label><?php echo $userdata['department_name'];?></td>
            <td><label>职位：</label><?php echo $userdata['position_name'];?></td>
            <td><label>入职时间：</label><?php echo date('Y-m-d',strtotime($userdata['enter_date']));?></td>
            <td><label>最后工作日：</label><?php echo date('Y-m-d',strtotime($base_data['plan_date']));?></td>
        </tr>
    </table>

    <form action="" method="post" class="p2">
        <ul>
        <?php $show_reason = 'display:none'; if($base_data['is_self'] || $base_data['is_super'] || $base_data['is_hr'] || ($base_data['is_close'] && $myinfo['user_id']==$base_data['user_id'])){
            $show_reason = '';
        }?>
            <li class="p2l1" style="<?=$show_reason?>">
                <b>离职原因</b>
                <label class="reason">
                <?=$base_data['dimiss_reason'][$base_data['reason_id']]?>
                <br>
                <?=$base_data['other_reason']?>
                </label>
            </li>
            <?php
            $disable_30 = "disabled";
            $style_show_30 = 'display:none';
            if(in_array(Const_Flow::PHASE_30, $base_data['is_allow_opt'])){
                $disable_30 = '';
                $style_show_30 = '';
            }
            if(empty($base_data["superior_opinion"])){
                $base_data["superior_opinion"] = 1;
            }
            $superior_check_30_1 = $base_data['superior_opinion']==1 ? 'checked' :'';
            $superior_check_30_2 = $base_data['superior_opinion']==2 ? 'checked' :'';
            $style_show_30 = ($base_data['is_super'] || $base_data['is_hr'] || ($base_data['is_close'] && $base_data['is_super'])) ? '' : $style_show_30;
            ?>
            <li class="p2l2" style="<?=$style_show_30?>">
                <b>直属主管审批</b>
            </li>
            <li class="p2l3" style="<?=$style_show_30?>">
            <input type="hidden" name="flow_opt[]" value="30" <?=$disable_30?>>
                <div>
                    <input type="radio" name="superior_opinion" value="1" <?=$superior_check_30_1?> <?=$disable_30?> />批准该申请
                    工作交接人<em>*</em>：<input type="text" name="handoff_user_name" style="width: 125px;" value="<?=htmlspecialchars($base_data['handoff_user_name'])?>" <?=$disable_30?> />
                    <input type="hidden" name="handoff_user_id" class="job_inherit" value="<?=$base_data['handoff_user_id']?>" <?=$disable_30?>  />
                    岗位继承人<?php if(!empty($base_data['has_sub'])):?> <em>*</em><?php endif;?>：<input type="text" name="after_user_name" style="width: 125px;" value="<?=htmlspecialchars($base_data['after_user_name'])?>" <?=$disable_30?> />
                    <input type="hidden" name="after_user_id" class="position_inherit" value="<?=$base_data['after_user_id']?>" <?=$disable_30?>  />
                </div>
                <div>
                    <input type="radio" name="superior_opinion" value="2" <?=$superior_check_30_2?> <?=$disable_30?> />驳回该申请<br/>
                    <label style="display:inline-block;height:20px;vertical-align:top; width:57px;" >原因：</label>
                    <textarea cols="20" rows="4" name="superior_bak" maxlength="90" <?=$disable_30?>><?=$base_data['superior_bak']?></textarea>
                </div>
            </li>
            <?php
            $disable_31 = "disabled";
            $style_show_31 = 'display:none';
            if(in_array(Const_Flow::PHASE_31, $base_data['is_allow_opt'])){
                $disable_31 = '';
                $style_show_31 = '';
            }
            $style_show_31 = ($base_data['is_super'] ||$base_data['is_hr'] || ($base_data['is_close'] && $myinfo['user_id']==$base_data['user_id']))  ? '' : $style_show_31;
            if($base_data['is_self']){
                $style_show_31='';
            }
            ?>
            <li class="p2l2" style="<?=$style_show_31?>">
                <b>本部门</b>
            </li>
            <li class="p2l3" style="<?=$style_show_31?>">
            <input type="hidden" name="flow_opt[]" value="31" <?=$disable_31?>>
                <div>
                    <label>交接资料：</label>
                    <textarea rows="4" cols="20" style="width: 400px;height: 80px;" maxlength="90" name="handoff_desc" <?=$disable_31?>><?=$base_data['handoff_desc']?></textarea>
                </div>
            </li>
            <?php
            $disable_32 = "disabled";
            $style_show_32 = 'display:none';
            if(empty($base_data["superior_re_opinion"])){
                $base_data["superior_re_opinion"] = 1;
            }
            $super_re_check_32_1 = $base_data['superior_re_opinion']==1 ? 'checked' :'';
            if(in_array(Const_Flow::PHASE_32, $base_data['is_allow_opt'])){
                $disable_32 = $style_show_32 = '';
            }
            $style_show_32 = ($base_data['is_super'] || $base_data['is_hr'] || ($base_data['is_close'] && $base_data['is_super']))  ? '' : $style_show_32;
            ?>
             <li class="p2l2" style="<?=$style_show_32?>">
                <b>直属主管</b>
            </li>
            <li class="p2l3" style="<?=$style_show_32?>">
            <input type="hidden" name="flow_opt[]" value="32" <?=$disable_32?>>
                <div>
                    <label>交接完成：</label><input type="radio" name="superior_re_opinion" value="1" <?=$super_re_check_32_1?> <?=$disable_32?> />是
                </div>
                <div>
                    <label>备注：</label><input type="text" style="width: 300px;" name="handoff_re_desc" value="<?=htmlspecialchars($base_data['handoff_re_desc'])?>" <?=$disable_32?> />
                </div>
            </li>
            <?php
            $disable_33 = "disabled";
            $style_show_33 = 'display:none';
            if(empty($base_data["uncleared_type"])){
                $base_data["uncleared_type"] = 0;
            }
            if(empty($base_data["uncleared_sale_type"])){
                $base_data["uncleared_sale_type"] = 0;
            }
            $uncleared_type_33_1 = $base_data['uncleared_type']==1 ? 'checked' :'';
            $uncleared_type_33_0 = $base_data['uncleared_type']==0 ? 'checked' :'';
            $uncleared_sale_type_33_1 = $base_data['uncleared_sale_type']==1 ? 'checked' :'';
            $uncleared_sale_type_33_0 = $base_data['uncleared_sale_type']==0 ? 'checked' :'';

            $uncleared_text = array();
            if(!empty($base_data['uncleared_text'])){
                $uncleared_text = explode(',',$base_data['uncleared_text']);
            }
            $uncleared_text_33_1 = in_array(1,$uncleared_text) ? 'checked' :'';
            $uncleared_text_33_2 = in_array(2,$uncleared_text) ? 'checked' :'';

            $uncleared_sale_text = array();
            if(!empty($base_data['uncleared_text'])){
                $uncleared_sale_text = explode(',',$base_data['uncleared_text']);
            }
            $uncleared_text_33_1 = in_array(1,$uncleared_sale_text) ? 'checked' :'';
            $uncleared_text_33_2 = in_array(2,$uncleared_sale_text) ? 'checked' :'';

            if(in_array(Const_Flow::PHASE_33, $base_data['is_allow_opt'])){
                $disable_33 = $style_show_33 ='';
            }
            $style_show_33 = ($base_data['is_hr'] || ($base_data['is_close'] && $myinfo['role_list'][Const_Flow::ROLE_FIN]))  ? '' : $style_show_33;
            ?>
             <li class="p2l2" style="<?=$style_show_33?>">
                <b>财务部</b>
            </li>

            <li class="p2l3" style="<?=$style_show_33?>">
                <input type="hidden" name="flow_opt[]" value="33" <?=$disable_33?>>
                <div>
                    <label>未结清款项：</label>
                    <input type="radio" name="uncleared_type" value="1" <?=$uncleared_type_33_1?> <?=$disable_33?> />
                    有（<input type="checkbox" name="uncleared_text[]" value="1" <?=$uncleared_text_33_1?>  <?=$disable_33?> />财务报销；<input type="checkbox" name="uncleared_text[]" value="2" <?=$uncleared_text_33_2?> <?=$disable_33?> />工资待扣）
                    金额：<input type="text" name="uncleared_money" value="<?=(empty($base_data['uncleared_money']) || $base_data['uncleared_money']=='0.00') ? '' : $base_data['uncleared_money'];?>" <?=$disable_33?> />
                </div>
                <div class="l3d">
                    <input type="radio" name="uncleared_type" value="0" <?=$uncleared_type_33_0?> <?=$disable_33?> />无
                </div>

                <div>
                    <label>未结清营销费用：</label><input type="radio" name="uncleared_sale_type" value="1" <?=$uncleared_sale_type_33_1?> <?=$disable_33?> />有（<input type="checkbox" name="uncleared_sale_text[]" value="1" <?=$uncleared_sale_text_33_1?>  <?=$disable_33?> />财务报销；
                    <input type="checkbox" name="uncleared_sale_text[]" value="2" <?=$uncleared_sale_text_33_2?>   <?=$disable_33?> />工资待扣）
                    金额：<input type="text" name="uncleared_sale_money" value="<?=(empty($base_data['uncleared_sale_money']) || $base_data['uncleared_sale_money']=='0.00') ? '' : $base_data['uncleared_sale_money'];?>" <?=$disable_33?> />
                </div>
                <p class="l3p1"> (仅销售人员)</p>
                <div class="l3d">
                    <input type="radio" name="uncleared_sale_type"  value="0" <?=$uncleared_sale_type_33_0?> <?=$disable_33?> />无
                </div>
                <div> <label>费用说明：</label><input type="text" name="uncleared_desc" value="<?=htmlspecialchars($base_data['uncleared_desc'])?>" <?=$disable_33?> /></div>
                <div> <label>备注：</label><input type="text" name="uncleared_bak" value="<?=htmlspecialchars($base_data['uncleared_bak'])?>" <?=$disable_33?> /></div>
            </li>

            <?php
            $disable_34 = "disabled";
            $style_show_34 = 'display:none';
            if($base_data['is_tech']){
                if(empty($base_data["book_back"])){
                    $base_data["book_back"] = 1;
                }
                $book_back_34_1 = $base_data['book_back']==1 ? 'checked' :'';
                $book_back_34_2 = $base_data['book_back']==2 ? 'checked' :'';
                if($base_data['is_tech'] && in_array(Const_Flow::PHASE_34, $base_data['is_allow_opt'])){
                    $disable_34 = $style_show_34='';
                }
                $style_show_34 = ($base_data['is_hr'] || ($base_data['is_close'] && $myinfo['role_list'][Const_Flow::ROLE_BOOK]))  ? '' : $style_show_34;
            }
            ?>
            <li class="p2l2" style="<?=$style_show_34?>">
                <b>技术部</b>
            </li>

            <li class="p2l3" style="<?=$style_show_34?>">
            <input type="hidden" name="flow_opt[]" value="34" <?=$disable_34?>>
                <div>
                    <label>书籍归还：</label><input type="radio" name="book_back" value="1" <?=$book_back_34_1?> <?=$disable_34?> />是<input type="radio" name="book_back" value="2" <?=$book_back_34_2?> <?=$disable_34?> />否
                </div>
                <div>
                    <label>备注：</label><input type="text" style="width: 300px;" name="book_bak" value="<?=htmlspecialchars($base_data['book_bak'])?>" <?=$disable_34?> />
                </div>
            </li>
            <?php
            $disable_35 = "disabled";
            $style_show_35 = 'display:none';
            $close_power_35_1 = $base_data['close_power']==1 ? 'checked' :'';
            if(in_array(Const_Flow::PHASE_35, $base_data['is_allow_opt'])){
                $disable_35 = $style_show_35 = '';
            }
            $style_show_35 = ($base_data['is_hr'] || ($base_data['is_close'] && $myinfo['role_list'][Const_Flow::ROLE_IT]))  ? '' : $style_show_35;
            ?>
            <li class="p2l2" style="<?=$style_show_35?>">
                <b>IT部</b>
            </li>

            <li class="p2l3" style="<?=$style_show_35?>">
            <input type="hidden" name="flow_opt[]" value="35" <?=$disable_35?>>
                <div>
                    <label style="margin-left: -106px;"></label>
                    <label>关闭权限：</label><input type="checkbox" name="close_power" value="1" <?=$close_power_35_1?> <?=$disable_35?> />已关闭
                    <span>域帐号：<?php echo $userdata['domain_account'];?></span>
                    <span>邮箱：<?php echo $userdata['office_mail'];?></span>
                    <!-- span>CRM帐号：<?php echo $userdata['crm_account'];?></span-->
                </div>
                <p class="l3d">（检查电脑相关软硬件，确保未受损坏，整理电脑至可供新员工适用的初始状态）</p>
                <div>
                    <label>备注：</label><input type="text" style="width: 300px;" name="close_bak" value="<?=$base_data['close_bak']?>" <?=$disable_35?> />
                </div>
            </li>
            <?php
            $disable_36 = "disabled";
            $style_show_36 = 'display:none';
            if(in_array(Const_Flow::PHASE_36, $base_data['is_allow_opt'])){
                $disable_36 = $style_show_36= '';
            }
            $style_show_36 = ($base_data['is_hr'] || ($base_data['is_close'] && $myinfo['role_list'][Const_Flow::ROLE_ADMIN]))  ? '' : $style_show_36;
            ?>
            <li class="p2l2" style="<?=$style_show_36?>">
                <b>行政部</b>
            </li>

            <li class="p2l3" style="<?=$style_show_36?>">
            <input type="hidden" name="flow_opt[]" value="36" <?=$disable_36?>>
                <div>
                    <label>收回：</label>
                    <?php $have_office_supply=array();
                    if(!empty($base_data['callback_type'])){
                        $have_office_supply = explode(',',$base_data['callback_type']);
                    }?>
                    <?php foreach($base_data['office_supply'] as $k=>$val):?>
                    <input type="checkbox" name="callback_type[]" value="<?=$k?>" <?php if(in_array($k,$have_office_supply)):?>checked<?php endif;?> <?=$disable_36?> /><?=$val?>
                    <?php if($k==5):?>
                    </div>
                <div>
                    <label>&nbsp;</label>
                    <?php endif;?>
                    <?php endforeach;?>
                    原分机号码：<input type="text" name="callback_phone" value="<?=htmlspecialchars($base_data['callback_phone'])?>" <?=$disable_36?> />
                </div>
                <div>
                    <label>备注：</label><input type="text" style="width: 300px;" name="callback_desc" value="<?=htmlspecialchars($base_data['callback_desc'])?>" <?=$disable_36?> />
                </div>
            </li>
            <?php
            $disable_37 = "disabled";
            $style_show_37 = 'display:none';
            if(empty($base_data["hr_opinion"])){
                $base_data["hr_opinion"] =2;
            }
            $work_book_1 = $base_data["work_book"]==1 ? 'checked' :'';

            $hr_opinion_37_1 = $base_data["hr_opinion"]==1 ? 'checked' :'';
            $hr_opinion_37_2 = $base_data["hr_opinion"]==2 ? 'checked' :'';
            if(empty($base_data["option"])){
                $base_data["option"] =2;
            }
            $option_37_1 = $base_data["option"]==1 ? 'checked' :'';
            $option_37_2 = $base_data["option"]==2 ? 'checked' :'';

            if(in_array(Const_Flow::PHASE_37, $base_data['is_allow_opt']) && !$base_data['is_close']){
                $disable_37 = $style_show_37='';
            }
            $last_date=$leaving_date='';
            if(!empty($base_data['last_date'])){
                $last_date = date('Y-m-d',strtotime($base_data['last_date']));
            }
            if(!empty($base_data['leaving_date'])){
                $leaving_date = date('Y-m-d',strtotime($base_data['leaving_date']));
            }
            $hr_leaving_type_1 = $base_data["hr_leaving_type"]==1 ? 'checked' :'';
            $hr_leaving_type_2 = $base_data["hr_leaving_type"]==2 ? 'checked' :'';
            $style_show_37 = ($base_data['is_hr'] || ($base_data['is_close'] && $myinfo['role_list'][Const_Flow::ROLE_HR]))  ? '' : $style_show_37;

            ?>
            <li class="p2l2" style="<?=$style_show_37?>">
                <b>人力资源部</b>
            </li>

            <li class="p2l3" style="<?=$style_show_37?>">
            <input type="hidden" name="flow_opt[]" value="37" <?=$disable_37?>>
                <div>
                    <label>撤销离职：</label>
                    <input type="radio" name="hr_opinion" value="1" <?=$hr_opinion_37_1?> <?=$disable_37?> />是
                    <input type="radio" name="hr_opinion" value="2" <?=$hr_opinion_37_2?> <?=$disable_37?> />否
                </div>
                <div>
                    <label>期权：</label><input type="radio" name="option" value="1" <?=$option_37_1?> <?=$disable_37?> />有，已办理
                    <input type="radio" name="option" value="2" <?=$option_37_2?> <?=$disable_37?> />无
                </div>
                <div>
                    <label>劳动手册：</label><input type="checkbox" name="work_book" value="1" <?=$work_book_1?> <?=$disable_37?> />已经返还
                </div>
                <div>
                    <label>已办理：</label>
                    <?php $have_hr_confirm=array();
                    if(!empty($base_data['hr_checked'])){
                        $have_hr_confirm = explode(',',$base_data['hr_checked']);
                    }?>
                    <?php foreach($base_data['hr_confirm_list'] as $k=>$val):?>
                    <input type="checkbox" name="hr_checked[]" value="<?=$k?>" <?php if(in_array($k,$have_hr_confirm)):?>checked<?php endif;?> <?=$disable_37?> /><?=$val?>
                    <?php endforeach;?>
                </div>
                <div>
                    <label>备注：</label><input type="text" style="width: 300px;" name="hr_bak" value="<?=htmlspecialchars($base_data['hr_bak'])?>" <?=$disable_37?> />
                </div>
                <div>
                    <label>最后工作日：</label><input class="datepicker" id="lastWorkDay" type="text" name="last_date" style="width: 100px;" value="<?=$last_date?>" <?=$disable_37?> />
                </div>

                <div>
                    <label>最后离职时间：</label><input class="datepicker" type="text" id="lastRetireDate" name="leaving_date" style="width: 100px;" value="<?=$leaving_date?>" <?=$disable_37?> />
                </div>
                <div>
                <label>离职类型：</label>
                <input type="radio" name="hr_leaving_type" value="1" <?=$hr_leaving_type_1?> <?=$disable_37?> onclick="javascript:$('#hr_reasion_id_1').show();$('#hr_reasion_id_2').hide();" />主动离职
                <input type="radio" name="hr_leaving_type" value="2" <?=$hr_leaving_type_2?>  <?=$disable_37?> onclick="javascript:$('#hr_reasion_id_2').show();$('#hr_reasion_id_1').hide();" />被动离职
                </div>
                <div>
                <label>离职原因：</label>
                <select name="hr_reasion_id_1" id="hr_reasion_id_1" <?php if($base_data['hr_leaving_type']==2):?>style="display:none"<?php endif;?> <?=$disable_37?>>
                <?php foreach($base_data['act_reason'] as $k=>$val):?>
                <option value="<?=$k?>" <?php if($base_data["hr_reason_id"]==$k):?>selected<?php endif;?>><?=$val?></option>
                <?php endforeach;?>
                </select>
                <select name="hr_reasion_id_2" id="hr_reasion_id_2" <?php if($base_data['hr_leaving_type']==1):?>style="display:none"<?php endif;?> <?=$disable_37?>>
                <?php foreach($base_data['passive_reason'] as $k=>$val):?>
                <option value="<?=$k?>" <?php if($base_data["hr_reason_id"]==$k):?>selected<?php endif;?>><?=$val?></option>
                <?php endforeach;?>
                </select>
                </div>
            </li>

            <li class="p2l2">&nbsp;</li>
            <li class="p2l5">
            <?php if($base_data['now_status']==1 && !empty($base_data["is_allow_opt"])):?>
                <input class="btn_sub" type="submit" value=""/>
            <?php elseif($base_data['now_status']==2 && $base_data['is_hr']):?>
            <a href="<?=Flow_Urls::flow_print().'?do=dimission&id='.$base_data['flow_id']?>" class="button" target="_blank">打印预览</a>
            <?php else:?>
            <?php endif;?>
            </li>
        </ul>
    </form>

</div>
<div class="footer">
</div>
    <?php $this->script_block_begin(); ?>
<script type="text/javascript">
var url_user = "<?php echo Portal_Urls::ajax_search_user();?>";
var url_job = "<?php echo Portal_Urls::ajax_search_job();?>";
var url_identity ="<?=Portal_Urls::ajax_id_card()?>";
</script>
<?php $this->script_block_end(); ?>